<?php include_once('header.php');?>
	<div class="main-content">
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
			<ul class="breadcrumb">
				<li>
					<i class="icon-home home-icon"></i>
					会员管理
				</li>
				<li>
					会员列表
				</li>
			</ul>
		</div>
		<div class="page-content">
			<div class="page-header">
				<h1 class="blue"><i class="icon-edit"></i> 编辑会员信息</h1>
			</div>
			<div class="row">
				<div class="col-xs-12">
					<form class="form-horizontal" enctype="multipart/form-data" role="form" method="post" action="/admin/user/edit" >
						<input type="hidden" id="id" name="id" value="<?php echo $data['id'];?>" />
						<!--<div class="form-group">
							<label for="title" class="col-sm-1 control-label">微信昵称:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" readonly="readonly" value="<?php echo $data['user_nick'];?>">
							</div>
						</div>													
						<div class="form-group">
							<label  class="col-sm-1 control-label">微信头像:</label>
							<div class="col-sm-4">
								<img src="<?php echo $data['avatar'];?>" style="max-height:160px;max-width:835px;" />
							</div>
						</div>-->
                                                <div class="form-group">
							<label for="title" class="col-sm-1 control-label">供位:</label>
							<div class="col-sm-6">
								<?php if($admin_type =='admin') {?>
									<select name="fora_id" id="fora_id" style="float: left;height: 34px;" onchange="$('#csg').val('');" >
										<?php
											$select='';
										foreach ($fora as $key => $value) {
												if($value['id']==$data['fora_id']){
													$select=' selected = "selected"';
												}
											echo ' <option '.$select.'value="' . $value['id'] . '">' . $value['name'] . '</option>';

										}

										?>
									</select>
								<?php }?>
								<?php if($admin_type=='admin'){?> <input type="text" class="form-control"  style="width:55%; display: inline-block;"  id="csg" name="csg" value="<?php echo $data['csg'];?>"><?php }else{echo $data['csg'];} ?>
								<?php if($admin_type =='admin') {?><a  id="check_fora" class="btn btn-primary" style="padding: 1px 2px;width: 40px; ">检索</a><?php }?>
							</div>
						</div>
                                                <div class="form-group">
							<label  class="col-sm-1 control-label">登录帐号:</label>
							<div class="col-sm-4">
								<?php if($admin_type=='admin'){?> <input type="text" class="form-control" onblur="check_name()" id="newusername" name="newusername" autocomplete="off" value="<?php echo $data['username'];?>"><?php }else{echo $data['username'];} ?>
                                                            <input type="hidden" class="form-control" id="username" name="username" value="<?php echo $data['username'];?>">
							</div>
						</div>
                                                <div class="form-group">
							<label  class="col-sm-1 control-label">登录密码:</label>
							<div class="col-sm-4">
								<input type="password" class="form-control" id="password1" autocomplete="off" name="password" value="">为空表示不修改
							</div>
						</div>
						<div class="form-group">
							<label  class="col-sm-1 control-label">二级密码:</label>
							<div class="col-sm-4">
								<input type="password" class="form-control" id="password2" autocomplete="off" name="password2" value="">为空表示不修改
							</div>
						</div>

						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">姓名:</label>
							<div class="col-sm-6">
								<?php if($admin_type=='admin'){?><input type="text" class="form-control" id="true_name" name="true_name" value="<?php echo $data['true_name'];?>"><?php }else{ echo $data['true_name'];} ?>
							</div>
						</div>
						<div class="form-group">
								<label for="title" class="col-sm-1 control-label">报单时间</label>
								<div class="col-sm-2">
									<?php if($admin_type=='admin'){?> <input type="text" class="Wdate form-control" name="s_time" value="<?=$data['s_time']?>" id="d412" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" /><?php }else{ echo $data['s_time'];} ?>
								</div>
							</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">手机号码:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" id="phone" name="phone" value="<?php echo $data['phone'];?>">
							</div>
						</div>
                                                <div class="form-group">
							<label for="title" class="col-sm-1 control-label">开户行:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" id="bank_name" name="bank_name" value="<?php echo $data['bank_name'];?>">
							</div>
						</div>
                                                <div class="form-group">
							<label for="title" class="col-sm-1 control-label">银行帐号:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" id="bank_account" name="bank_account" value="<?php echo $data['bank_account'];?>">
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">联系地址:</label>
							<div class="col-sm-6">				
								<select name="province" id="province">
									<?php 
										foreach($area_list as $key => $value) {
											if($value['areano'] == $area_array[0]) {
												echo ' <option value="'.$value['areano'].','.$value['areaname'].'" selected = "selected">'.$value['areaname'].'</option>';
											}else {
												echo ' <option value="'.$value['areano'].','.$value['areaname'].'">'.$value['areaname'].'</option>';
											}									
										}
									
									?>
								</select>						 
								<select name="city" id="city">						 
									<?php 
										foreach($city_list as $key => $value) {
											if($value['areano'] == $area_array[1]) {
												echo ' <option value="'.$value['areano'].','.$value['areaname'].'" selected = "selected">'.$value['areaname'].'</option>';
											}else {
												echo ' <option value="'.$value['areano'].','.$value['areaname'].'">'.$value['areaname'].'</option>';
											}									
										}
									
									?>
								</select>					 
								<select name="county" id="county">							  
									<?php 
										foreach($county_list as $key => $value) {
											if($value['areano'] == $area_array[2]) {
												echo ' <option value="'.$value['areano'].','.$value['areaname'].'" selected = "selected">'.$value['areaname'].'</option>';
											}else {
												echo ' <option value="'.$value['areano'].','.$value['areaname'].'">'.$value['areaname'].'</option>';
											}									
										}
									
									?>
								</select>
							</div>							
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">详细地址:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" id="address" name="address" value="<?php echo $data['address'];?>">
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">备注:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" id="remark" name="remark" value="<?php echo $data['remark'];?>">
							</div>
						</div>
					 	<div class="form-group">
					   		<div class="col-sm-offset-1 col-sm-10">
								<button type="submit" id="submit" class="btn btn-primary">确定</button>
								<button type="submit" id="cancel" class="btn btn-primary">取消</button>
							</div>
					  	</div>
					</form>	
				</div>
			</div>					
		</div>													
	</div>
<?php include_once('content.php');?>
	<link href="/public_source/www/assets/css/ace.min.css" rel="stylesheet" />	
	<link href="/public_source/www/assets/css/jquery.tag-editor.css" rel="stylesheet"/>
        <link  rel="stylesheet" href="/public_source/www/assets/css/jquery-confirm.css" />
	<link  rel="stylesheet" href="/public_source/www/css/confirm.css" />
<link  rel="stylesheet" href="/public_source/www/assets/css/jquery-ui.css" />
    <script src="/public_source/www/assets/js/bootbox.min.js"></script>  
	<script src="/public_source/www/assets/js/jquery.tag-editor.min.js"></script>
<script src="/public_source/www/assets/js/jquery-ui.js"></script>
	<script src="/public_source/www/js/areas.js"></script>
	<script src="/public_source/www/My97DatePicker/WdatePicker.js"></script> 
        <script src="/public_source/www/assets/js/jquery-confirm.js"></script>
<?php include_once('footer.php');?>	
<script type="text/javascript">
	$(document).ready(function(){
		$("#cancel").click(function() {
			window.location.replace('/admin/user/user_list');
			return false;
		});
	});
	<?php if($admin_type =='admin'){?>
	$(function () {
		var old_csg='';
		$("#check_fora").click(function (){
			var fora_id=$('#fora_id option:selected').val();
			var  keyword=$('#csg').val();

			if(keyword!='' && keyword != old_csg){
				old_csg=keyword;

				var data={fora_id:fora_id,keyword:keyword};
				$.ajax({
					url:"/admin/fora/get_fora_log",
					async: false,
					type:"post",
					data: data,
					dataType: 'json',
					success:function(data) {
						var li_html='';
						//console.log(data.length);
						if(data.length >0){
							for(var i=0;i<data.length;i++){
								li_html+='<li class="ui-menu-item" role="presentation"><a id="ui-id-'+i+'" class="ui-corner-all fora_code"data-code="'+data[i]["code"]+'" tabindex="-1">'+data[i]["fora_name"]+'/'+data[i]["code"]+'</a></li>';
							}
						}else{
							li_html='<li class="ui-menu-item" role="presentation"><a class="ui-corner-all " tabindex="-1">未查询到供位</a></li>';
						}
						$('#ui-id-1').show();
						$('#ui-id-1').html(li_html);
						$('.fora_code').click(function(){
							$('#csg').val($(this).data('code'));
							$('#ui-id-1').hide();
						});
					}
				});
			}else{
				$('#ui-id-1').show();
			}
		});
	});
	<?php }?>
        function check_name(){
            var newusername = document.getElementById("newusername").value;
            var id = document.getElementById("id").value;
            var data={id:id,newusername:newusername};
            if(newusername == null || newusername==''){
                $.alert({
                    title: '提示',
                    content:'登录名不能为空',
                    confirm: function(){
                    }
                });
                 return false;
            }else{
                var bool=true;
                $.ajax({
			url:"/admin/user/check_name",
			async: false,
			type:"post",
			data: data,
			dataType: 'json',
			success:function(data) {
				bool = data;
			}	
		});
                if(!bool) {
		   	$.alert({
			    title: '提示',
			    content:'登录名不能重复',
			    confirm: function(){
			    }
			});
			return false;	
		}
            }
        }
	function check() {
	   var username = document.getElementById("username").value;
	   var phone = document.getElementById("phone").value;
           alert(phone);
	   var address = document.getElementById("address").value;
	   var phoneReg=/^0?1[3584][0-9][0-9]{8}$/;
	   if(username ==  null || username == '') {
	        alert("姓名不能为空");
	        return false;
	   }
	   if(phone ==  null || phone == '') {
	        alert("手机号码不能为空");
	        return false;
	   }
	   if(!phoneReg.test(phone)){
	        alert("手机号码格式错误");
	        return false
	 	}
	   if(address ==  null || address == '') {
	        alert("详细地址不能为空");
	        return false;
	   }

		<?php if($admin_type =='admin'){ ?>
		var csg = document.getElementById("csg").value;
		var data={csg:csg};
		var bool=true;
		$.ajax({
			url:"/admin/fora/check_fora_log",
			async: false,
			type:"post",
			data: data,
			dataType: 'json',
			success:function(data) {
				bool = data;
			}
		});
		if(!bool) {
			$.alert({
				title: '提示',
				content:'供位编号不存在或已被使用',
				confirm: function(){
				}
			});
			return false;
		}else{
			return true;
		}
		<?php }?>
	   return true;
	}			
</script>
<ul class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content ui-corner-all" id="ui-id-1" tabindex="0" style=" display: none; top: 190px;    left: 24%;   width: 23%;"></ul>